﻿using ASPNETVN.PORTAL.Components.UI;
using System;
using ASPNETVN.PORTAL.Components.Helpers;
using WEATHER.Components;

namespace WEATHER.Modules.MANAGEMENT
{
    public partial class ItemManager : AddEditModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string url = HttpUrlBuilder.BuildAddEditUrl(this.ModuleID, 0, "AddEditItem");
            Response.Redirect(url);
        }

        protected void btnGetData_Click(object sender, EventArgs e)
        {
            string url = HttpUrlBuilder.BuildModulePageUrl(this.ModuleID, 0, ModulePages.ItemSpider);
            Response.Redirect(url);
        }

        protected void btnDeleteData_Click(object sender, EventArgs e)
        {
            string where = string.Format("DATEDIFF(DAY, CreatedDate, GETDATE()) >= {0}", txtDay.Text);
            Item.DeleteDynamic(where);
            this.ShowMessage("Thông Báo", "Xóa thành công!");
            sdsWeatherItems.DataBind();
        }
    }
}